// 清除浮动
@mixin clearfix {
  &::after {
    content: '';
    display: table;
    clear: both;
  }
}

// 文本省略
@mixin ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 多行文本省略
@mixin ellipsis-multiline($lines: 2) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

// 居中对齐
@mixin center {
  display: flex;
  align-items: center;
  justify-content: center;
}

// 垂直居中
@mixin vertical-center {
  display: flex;
  align-items: center;
}

// 水平居中
@mixin horizontal-center {
  display: flex;
  justify-content: center;
}

// 绝对定位居中
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 响应式断点
@mixin respond-to($breakpoint) {
  @if $breakpoint ==xs {
    @media (max-width: #{$breakpoint-xs - 1px}) {
      @content;
    }
  }

  @if $breakpoint ==sm {
    @media (min-width: #{$breakpoint-sm}) {
      @content;
    }
  }

  @if $breakpoint ==md {
    @media (min-width: #{$breakpoint-md}) {
      @content;
    }
  }

  @if $breakpoint ==lg {
    @media (min-width: #{$breakpoint-lg}) {
      @content;
    }
  }

  @if $breakpoint ==xl {
    @media (min-width: #{$breakpoint-xl}) {
      @content;
    }
  }

  @if $breakpoint ==xxl {
    @media (min-width: #{$breakpoint-xxl}) {
      @content;
    }
  }
}

// 按钮样式
@mixin button-variant($color, $background, $border) {
  color: $color;
  background-color: $background;
  border-color: $border;

  &:hover {
    color: $color;
    background-color: lighten($background, 10%);
    border-color: lighten($border, 10%);
  }

  &:active {
    color: $color;
    background-color: darken($background, 10%);
    border-color: darken($border, 10%);
  }

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}

// 卡片样式
@mixin card {
  background: $bg-color;
  border-radius: $card-border-radius;
  box-shadow: $card-shadow;
  padding: $card-padding;
  transition: $transition-base;

  &:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  }
}

// 输入框样式
@mixin input {
  width: 100%;
  height: $input-height;
  padding: $input-padding;
  border: 1px solid $border-color;
  border-radius: $input-border-radius;
  font-size: $font-size-base;
  transition: $transition-border;

  &:focus {
    border-color: $primary-color;
    outline: none;
  }

  &:disabled {
    background-color: $bg-color-page;
    cursor: not-allowed;
  }
}

// 滚动条样式
@mixin scrollbar($width: 6px, $track-color: $scrollbar-track-color, $thumb-color: $scrollbar-thumb-color) {
  &::-webkit-scrollbar {
    width: $width;
    height: $width;
  }

  &::-webkit-scrollbar-track {
    background: $track-color;
    border-radius: $width / 2;
  }

  &::-webkit-scrollbar-thumb {
    background: $thumb-color;
    border-radius: $width / 2;

    &:hover {
      background: darken($thumb-color, 10%);
    }
  }
}

// 加载动画
@mixin loading-spinner($size: 20px, $border-width: 2px, $color: $primary-color) {
  display: inline-block;
  width: $size;
  height: $size;
  border: $border-width solid $border-color;
  border-top: $border-width solid $color;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

// 旋转动画
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

// 淡入动画
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

// 淡出动画
@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

// 滑入动画
@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

// 滑出动画
@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }

  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

// 缩放动画
@keyframes zoomIn {
  from {
    transform: scale(0.3);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

// 弹跳动画
@keyframes bounce {

  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  40%,
  43% {
    transform: translate3d(0, -30px, 0);
  }

  70% {
    transform: translate3d(0, -15px, 0);
  }

  90% {
    transform: translate3d(0, -4px, 0);
  }
}

// 脉冲动画
@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

// 摇摆动画
@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-10px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(10px);
  }
}